package com.vkmessenger.core.media;

import android.media.MediaPlayer;
import com.vkmessenger.gui.components.AudioPanel;

import java.lang.ref.WeakReference;

/**
 * Created by IntelliJ IDEA.
 * User: Evgeniy Krasko
 * Date: 23.06.12
 * Time: 18:42
 */
public class MediaPlayerFactory {
    private static WeakReference<AudioPanel> owner = new WeakReference<AudioPanel>(null);
    private static MediaPlayer player = new MediaPlayer();


    public static MediaPlayer retrieveMediaPlayer(AudioPanel me) {
        AudioPanel prev = owner.get();
        if (prev != null) {
            prev.releaseMediaPlayer();
        }
        player.reset();
        owner = new WeakReference<AudioPanel>(me);
        return player;
    }
}
